package com.tanxi521.commandmanager;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

public class AutoRestartTimer extends Thread {

    private static final long PERIOD_DAY = 1000 * 60 * 60 * 24;

    private Timer timer;

    @Override
    public void run() {

        String restartTime = CommandManager.ConfigReader.getRestartTime();
        String[] split = restartTime.split(":");
        int hour = Integer.parseInt(split[0]);
        int min = Integer.parseInt(split[1]);
        int sec = Integer.parseInt(split[2]);
        Calendar now = Calendar.getInstance();
        now.set(Calendar.HOUR, hour);
        now.set(Calendar.MINUTE, min);
        now.set(Calendar.SECOND, sec);
        Date time = now.getTime();
        if (time.getTime() < System.currentTimeMillis()) {
            now.add(Calendar.DAY_OF_MONTH, 1);
        }
        // 重启时间
        time = now.getTime();



        super.run();
    }
}
